<?
    class AuthController extends PrincipioLab_Controller_Action
    {
        public function indexAction()
        {
            $auth = Zend_Auth::getInstance();
            if ($auth->hasIdentity())
            {
                $this->_redirect("/");
            }
            else
            {
                $this->_helper->layout->setLayout("login");
                if ($post_data = $this->post_data)
                {
                    if (isset($post_data["enter"]))
                    {
                        if (($model_user = Principio_Model_UserMapper::authorize($post_data["login"], $post_data["password"])) !== false)
                            $this->_redirect("/");
                        else
                            Principio_Common::reportError("Invalid Login/Password");
                    };
                };
            };
        }

        public function logoutAction ()
        {
            Zend_Auth::getInstance()->clearIdentity();
            $this->_redirect("/auth");
        }
	}
